package com.skyline.base.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.skyline.base.model.Share;
import com.skyline.base.type.ShareType;

/**
 * Share的Mapper
 * 
 * @author jairus
 * @version 0.1
 * 
 */
public class ShareMapper implements RowMapper<Share> {
	private static final ShareMapper MAPPER = new ShareMapper();

	public static ShareMapper getMapper() {
		return MAPPER;
	}

	public Share mapRow(ResultSet rs, int rowNum) throws SQLException {
		Share s = new Share();
		s.setCommentNum(rs.getInt("commentNum"));
		s.setCreateTime(rs.getTimestamp("createTime"));
		s.setDown(rs.getInt("down"));
		s.setId(rs.getLong("id"));
		// s.setResourceContent(rs.getString("resourceContent"));
		s.setResourceDigest(rs.getString("resourceDigest"));
		s.setResourceId(rs.getLong("resourceId"));
		s.setResourceOwnerId(rs.getLong("resourceOwnerId"));
		s.setResourceOwnerNickname(rs.getString("resourceOwnerNickname"));
		s.setResourceOwnerPortrait(rs.getString("resourceOwnerPortrait"));
		s.setResourceSourceId(rs.getLong("resourceSourceId"));
		s.setResourceSoureceName(rs.getString("resourceSoureceName"));
		s.setResourceTitle(rs.getString("resourceTitle"));
		s.setShareNum(rs.getInt("shareNum"));
		s.setSharerId(rs.getLong("sharerId"));
		s.setSharerNickname(rs.getString("sharerNickname"));
		s.setSharerPortrait(rs.getString("sharerPortrait"));
		s.setUp(rs.getInt("up"));
		s.setShareType(ShareType.valueOf(rs.getString("shareType")));
		return s;
	}
}
